package com.huawei.java.main;

import com.huawei.java.main.classes.Day;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

public class Output {
    private final List<Day> days;

    public Output() {
        this.days = new ArrayList<>();
    }

    public void addDay(Day day) {
        days.add(day);
    }

    public void print(OutputStream stdout) throws IOException {
        final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdout));
        for (Day day : days) {
            writer.write(day.toString());
            writer.newLine();
        }
        writer.flush();
    }
}
